﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcmyjobs.Web.enprise
{
    public partial class Isemp : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Application["webname"] != null)
                {
                    this.Title = string.Format("单位管理中心—安全保密设置：招聘状态  {0}", Application["webname"].ToString());
                }
                if (Session["enterprise_bid"] != null)
                {
                    int enterprise_bid = Convert.ToInt32(Session["enterprise_bid"]);
                    Bind(enterprise_bid);
                }
                else
                {
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this, "请先登陆！", "EnterpriseLogin.html");
                }
            }
        }

        protected void lbn_save_Click(object sender, EventArgs e)
        {
            lcmyjobs.Model.enterprise_basic eb = new Model.enterprise_basic();

            if (this.rdo_0.Checked)
            {
                eb.isemp = false;
            }
            else
            {
                eb.isemp = true;
            }

            if (Session["enterprise_bid"] != null)
            {
                int enterprise_bid = Convert.ToInt32(Session["enterprise_bid"]);
                eb.enterprise_bid = enterprise_bid;

                if (new lcmyjobs.BLL.enterprise_basic().UpdateIsemp(eb))
                {
                    Maticsoft.Common.MessageBox.Show(this, "更新招聘状态成功！");
                    Bind(enterprise_bid);
                }
            }
        }

        private void Bind(int enterprise_bid)
        {
            lcmyjobs.Model.enterprise_basic eb = new lcmyjobs.BLL.enterprise_basic().GetModel(enterprise_bid);

            this.lbl_title.Text = " " + eb.name;

            if (!Convert.IsDBNull(eb.isemp))
            {
                if (eb.isemp.Value)
                {
                    this.lbl_isemp.Text = "招聘中";
                    this.rdo_1.Checked = true;
                }
                else
                {
                    this.lbl_isemp.Text = "已停止招聘";
                    this.rdo_0.Checked = true;
                }
            }


        }
    }
}